<?php
namespace Admin\Model;
use Think\Model;

/**
 * Class UserModel
 * @package Admin\Model
 */
class UserModel extends Model{
    protected $_validate=array(
        array('user_name','require','用户名不能为空'),
        array('user_name','3,16','用户名必须为3到16位',2,'length'),
        array('pwd','require','密码不能为空'),
        array('pwd','3,16','密码必须为4到16位',2,'length')
    );
    /**
     * test userName Pwd
     * @param $name
     * @param $pwd
     * @return bool|mixed
     */
    public function checkNamePwd($name,$pwd){
        if (empty($name) || empty($pwd)){
            return false;
        }
        $info=$this->where("user_name='$name'")->find();
        if ($info){
            if ($info['pwd'] === $pwd){
                return $info;
            }
            return false;
        }
    }
    /**
     * test code
     * @param $code
     * @return bool
     */
    public function check_verify($code){
        $verify = new \Think\Verify();
        return $verify->check($code);
    }
}